package com.ymttest.database.sqlwapper.shenqisettlement;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ymt.core.tool.Logger;
import com.ymt.database.SqlManager;
import com.ymttest.database.model.shenqisettlement.PlatformFeeSetting;

public class PlatformFeeSettingWrapper {

	SqlManager manager;

    public PlatformFeeSettingWrapper() {
        manager = new SqlManager("shenqisettlement");
    }
    
    @SuppressWarnings("unchecked")
	public PlatformFeeSetting selectByTypeAndIsDirect(String feeType, boolean isDirect, String country, int payMode) {
    	
    	Map<String, Object> m = new HashMap<String, Object>();
    	
    	m.put("feeType", feeType);
    	m.put("isDirect", isDirect);
    	m.put("country", country);
    	m.put("payMode", payMode);
    	
    	List<PlatformFeeSetting> result = manager
                .getSelectResults(
                        "com.ymttest.database.mapping.shenqisettlement.PlatformFeeSettingMapper.selectByTypeAndIsDirect",
                        m);
        manager.commit();
        
		if (result.size() == 0) {
			Logger.comment("platform_fee_setting没有数据");
			
			return null;
		}
		
		return result.get(0);
    }
    
    @SuppressWarnings("unchecked")
	public PlatformFeeSetting selectBySellerIdAndIsDirect(boolean isDirect, Long sellerId, int payMode) {
    	
    	Map<String, Object> m = new HashMap<String, Object>();
    	
    	m.put("feeType", "GOODS_OWNER");
    	m.put("isDirect", isDirect);
    	m.put("seller_id", sellerId);
    	m.put("payMode", payMode);
    	
    	List<PlatformFeeSetting> result = manager
                .getSelectResults(
                        "com.ymttest.database.mapping.shenqisettlement.PlatformFeeSettingMapper.selectBySellerIdAndIsDirect",
                        m);
        manager.commit();
        
		if (result.size() == 0) {
			Logger.comment("platform_fee_setting没有数据");
			
			return null;
		}
		
		return result.get(0);
    }
	
    public static void main(String[] args) {
    	
    	PlatformFeeSettingWrapper test = new PlatformFeeSettingWrapper();
    	
    	System.out.println(test.selectByTypeAndIsDirect("GOODS_OWNER", true, null, 1).getFee_rate());
    }
}
